{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "f0319b15-6bb5-4b4d-ad33-df2a565e10dc",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "通过了面试,拿到了企业的offer\n"
     ]
    }
   ],
   "source": [
    "# coding:UTF-8\n",
    "source = 93\n",
    "if source >= 90:\n",
    "    print('通过了面试,拿到了企业的offer')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "4a48f23a-9df7-43ef-bb3e-11ec1f449ce2",
   "metadata": {},
   "outputs": [],
   "source": [
    "# coding:UTF-8\n",
    "month = 5\n",
    "weekend = 6\n",
    "date = 7\n",
    "day = 10\n",
    "\n",
    "if month == 5 and weekend == 6 and date == 0 and day < 15:\n",
    "    print('5月的第二个星期日，继续努力学习')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d2536029-368d-4507-a8db-0b65402c44b4",
   "metadata": {},
   "source": [
    "以上是针对时间的一个操作，还可以通过联合的比较表达式来进行操作"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "a82902b8-f78c-499a-8352-2631786f935e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdin",
     "output_type": "stream",
     "text": [
      "请输入您的年龄： 20\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "这是一个大学生的年龄阶段，拥有无穷的探索精神！\n"
     ]
    }
   ],
   "source": [
    "# coding:UTF-8\n",
    "# age = 20    # 定义整型变量\n",
    "age = input('请输入您的年龄：')\n",
    "age_result = int(age)\n",
    "if 18 < age_result <= 22:   # 分支语句 设置区间范围\n",
    "    print('这是一个大学生的年龄阶段，拥有无穷的探索精神！')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "93e7e9e4-0c64-493e-9223-8ecb1308eed7",
   "metadata": {},
   "outputs": [
    {
     "name": "stdin",
     "output_type": "stream",
     "text": [
      "请输入您的用户名： admin\n",
      "请输入您的密码： 12345\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "登陆成功！即将进入主界面！\n"
     ]
    }
   ],
   "source": [
    "# coding:UTF-8\n",
    "user_name = \"admin\"\n",
    "password = \"12345\"\n",
    "\n",
    "user_name = input(\"请输入您的用户名：\")\n",
    "password = input(\"请输入您的密码：\")\n",
    "\n",
    "if user_name == \"admin\" and password == \"12345\":\n",
    "    print('登陆成功！即将进入主界面！')\n",
    "else:\n",
    "    print('您输入的用户名或密码错误，请重新输入！')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "ee2ae985-3982-4fce-b5bc-3bdcb660aa55",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "开心地去旅行\n"
     ]
    }
   ],
   "source": [
    "# coding:UTF-8\n",
    "money = 180000.8\n",
    "if money >= 180000.8:\n",
    "    print('开心地去旅行')\n",
    "else:\n",
    "    print('赚钱')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "87d546b3-071d-4035-9753-aaff589afb21",
   "metadata": {},
   "outputs": [],
   "source": [
    "# coding:UTF-8\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "f60a7de0-0717-4139-90b4-bab5974297dc",
   "metadata": {},
   "outputs": [
    {
     "name": "stdin",
     "output_type": "stream",
     "text": [
      "请输入您的成绩： 99.9\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "优秀\n"
     ]
    }
   ],
   "source": [
    "# 判断学生成绩，手动输入学生成绩\n",
    "# 当学生成绩为90-100为优秀\n",
    "# 当学生成绩为89-80为优良\n",
    "# 当学生成绩为79-70为良好\n",
    "# 当学生成绩为69-60为及格\n",
    "# 当学生成绩为60以下 则重修\n",
    "score = input('请输入您的成绩：')\n",
    "score = float(score)\n",
    "if 90 <= score <= 100:\n",
    "    print('优秀')\n",
    "elif 80 <= score < 90:\n",
    "    print('优良')\n",
    "elif 70 <= score < 80:\n",
    "    print('良好')\n",
    "elif 60 <= score < 70:\n",
    "    print('及格')\n",
    "else:\n",
    "    print('重修')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9fd08155-06ed-4df3-9c1d-0f271a2d4903",
   "metadata": {},
   "source": [
    "#### 三目运算符\n",
    "值1 if 条件 else 值2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "04e34b44-cd3c-4a37-87f3-b7795adb2b39",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2\n"
     ]
    }
   ],
   "source": [
    "# coding:UTF-8\n",
    "a = 1\n",
    "b = 2\n",
    "\n",
    "c = a if a > b else b   # 三目运算符\n",
    "print(c)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "78095f2f-560a-498b-852e-3cbcbec064c8",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2022年2月有28天\n"
     ]
    }
   ],
   "source": [
    "# 判断年份的和月份的天数\n",
    "# coding:UTF-8\n",
    "year = 2022\n",
    "month = 2\n",
    "if month in [1, 3, 5, 7, 8, 10, 12]:\n",
    "    print('%d月有31天' % month)\n",
    "elif month in [4, 6, 9, 11]:\n",
    "    print('%d月有30天' % month)\n",
    "elif month == 2:\n",
    "    if year % 400 == 0 or (year % 4 == 0 and year % 100 != 0):\n",
    "        print('%d年%d月有29天' % (year, month))\n",
    "    else:\n",
    "        print('%d年%d月有28天' % (year, month))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "94c83898-032f-48d8-b7af-98c50420896a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2024年是闰年\n",
      "1900年不是闰年\n"
     ]
    }
   ],
   "source": [
    "# 通过定义函数来判断是否是闰年\n",
    "def is_lear_year(year):\n",
    "    if (year % 4 == 0 and year % 100 != 0) or (year % 400 == 0):\n",
    "        print(f'{year}年是闰年')\n",
    "    else:\n",
    "        print(f'{year}年不是闰年')\n",
    "        \n",
    "# 调用函数\n",
    "is_lear_year(2024)   # 2024是闰年\n",
    "is_lear_year(1900)   # 1900不是闰年"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "52c4affd-d923-4a2a-a4d7-5604bca924b2",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
